package com.example.zuoye.dao;

import com.example.zuoye.entity.Cart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CartDAO {
    /**
     * 商品加入购物车
     * @param objId
     * @param userId
     * @return
     */
    @Insert("insert into cart (obj_id,user_id) values(#{objId},#{userId})")
    boolean addCart(String objId,String userId);

    /**
     * 删除商品从购物车中
     * @param objId
     * @param userId
     * @return
     */
    @Delete("delete from cart where obj_id = #{objId} and user_id = #{userId}")
    boolean deleteCart(String objId,String userId);

    /**
     * 查找该商品是否已被加入购物车
     * @param objId
     * @param userId
     * @return
     */
//    @Select("select * from cart where obj_id = #{objId} and user_id = #{userId}")
    Cart checkedCart(String objId,String userId);

    /**
     * 查询当前用户的购物车
     * @param userId
     * @return
     */
//    @Select("select good_name,good_price,good_introduce,good_date,good_number,good_image,good.good_id from cart inner join good on cart.obj_id = good.good_id where user_id=#{userId}")
    List<Cart> getListCart(String userId);
}
